
package com.hlkj.pay.controller.openapi.callback;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.hlkj.pay.app.merchant.IMerchantChannelAppService;
import com.hlkj.pay.app.merchant.ext.MerchantExtConstant;
import com.hlkj.pay.app.order.ISettleOrderAppService;
import com.hlkj.pay.controller.BaseController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

/**
 * @author HlpayTeam
 * @date 2024/09/12 11:32
 */
@Tag(name = "商户进件开户第三方回调")
@RestController
@RequestMapping("")
@RequiredArgsConstructor
public class MerchantChannelCallBackController extends BaseController {

    private final IMerchantChannelAppService merchantChannelAppService;
    private final ISettleOrderAppService merchantAccessSettleAppService;

    @Operation(summary = "进件结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_ACCESS_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String accessCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.accessCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "进件结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_ACCESS_STATUS_CALLBACK_URL + "/{channelCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String accessCallBack(@PathVariable("channelCode") String channelCode, HttpServletRequest request) {
        return merchantChannelAppService.accessCallBack(channelCode, request);
    }

    @Operation(summary = "业务开通审核结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_BUSINESS_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String businessApproveCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.businessApproveCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "业务开通成功结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_BUSINESS_SUCCESS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String businessSuccessCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.businessSuccessCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "报备结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_REPORT_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String reportCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.reportApproveCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "报备结果回调")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_REPORT_STATUS_CALLBACK_URL + "/{channelCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String reportCallBack(@PathVariable("channelCode") String channelCode, HttpServletRequest request) {
        return merchantChannelAppService.reportApproveCallBack(channelCode, request);
    }

    @Operation(summary = "电子户入金通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_REPORT_AMOUNT_STATUS_CALLBACK_URL + "/{channelCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String reportAmountCallBack(@PathVariable("channelCode") String channelCode, HttpServletRequest request) {
        return merchantChannelAppService.reportAmountCallBack(channelCode, request);
    }
    @Operation(summary = "电子户入金通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_REPORT_AMOUNT_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String reportAmountCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode")String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.reportAmountCallBack(channelCode,providerCode, request);
    }

    @Operation(summary = "资金调拨结果通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_REPORT_ALLOT_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String reportAllotCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantChannelAppService.reportAllotCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "结算结果通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_SETTLE_STATUS_CALLBACK_URL + "/{channelCode}/{providerCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String settleCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, HttpServletRequest request) {
        return merchantAccessSettleAppService.settleCallBack(channelCode, providerCode, request);
    }

    @Operation(summary = "易生拆分结果通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_CHANNEL_SPLIT_CALLBACK_URL + "/{channelCode}/{providerCode}/{requestId}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String easySplitCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, @PathVariable("requestId") String requestId, HttpServletRequest request) {
        return merchantChannelAppService.easySplitCallBack(channelCode, providerCode, requestId, request);
    }
    @Operation(summary = "test结果通知 部分渠道必须回调 直接返回处理成功")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_CHANNEL_SPLIT_CALLBACK_URL + "/{channelCode}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String testCallBack(@PathVariable("channelCode") String channelCode, HttpServletRequest request) {
        return merchantChannelAppService.testCallBack(channelCode,request);
    }

    @Operation(summary = "产品变更结果通知")
    @RequestMapping(value = MerchantExtConstant.MERCHANT_PRODUCT_UPDATE_CALLBACK_URL + "/{channelCode}/{providerCode}/{requestId}", produces = "text/plain", method = {RequestMethod.GET, RequestMethod.POST})
    String productUpdateCallBack(@PathVariable("channelCode") String channelCode, @PathVariable("providerCode") String providerCode, @PathVariable("requestId") String requestId, HttpServletRequest request) {
        return merchantChannelAppService.productUpdateCallBack(channelCode, providerCode, requestId, request);
    }


}
